package com.xhwl.logistics.controller;

import com.xhwl.common.pojo.ResultJson;
import com.xhwl.logistics.bo.VehicleCarRecordInParkingLotBO;
import com.xhwl.logistics.bo.cent.VehicleIntegratedConfigBO;
import com.xhwl.logistics.component.LookupVehicleParkingLotHandler;
import com.xhwl.logistics.converter.mapstruct.VehicleCarConverter;
import com.xhwl.logistics.dto.query.VehicleCarRecordInParkingLotDTO;
import com.xhwl.logistics.service.cent.QueryDeviceService;
import com.xhwl.logistics.strategy.IVehicleParkingLotHandler;
import com.xhwl.logistics.vo.VehicleCarRecordInParkingLotVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

//@RestController
public class VehicleCarController {

    @Autowired
    private LookupVehicleParkingLotHandler lookupVehicleParkingLotHandler;

    @Autowired
    private QueryDeviceService queryDeviceService;

    @Autowired
    private VehicleCarConverter vehicleCarConverter;

    @PostMapping("/car-record/detail-in-parking-lot")
    public ResultJson<VehicleCarRecordInParkingLotVO> carRecordInParkingLot(@RequestBody VehicleCarRecordInParkingLotDTO vehicleCarRecordInParkingLotDTO) {

        VehicleIntegratedConfigBO vehicleIntegratedConfigBO = queryDeviceService.queryIntegratedConfigFromProjectId(vehicleCarRecordInParkingLotDTO.getProjectId());

        IVehicleParkingLotHandler vehicleParkingLotHandler = lookupVehicleParkingLotHandler.lookup(vehicleIntegratedConfigBO.getVehicleSystemInfoBO().getProductId());
        VehicleCarRecordInParkingLotBO vehicleCarRecordInParkingLotBO = vehicleParkingLotHandler.queryCarRecordInParkingLot(vehicleIntegratedConfigBO, vehicleCarConverter.vehicleCarRecordInParkingLotDTO2QueryVehicleCarRecordInParkingLotBO(vehicleCarRecordInParkingLotDTO));

        return ResultJson.successWithResult(vehicleCarConverter.vehicleCarRecordInParkingLotBO2VehicleCarRecordInParkingLotVO(vehicleCarRecordInParkingLotBO));
    }

}
